Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / the jucer / src / utility / jucer_StoredSettings.cpp
blobd7adc126e108565d3f6c733e7c23bd3857fcf040
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../jucer_Headers.h"
27 #include "jucer_StoredSettings.h"
30 //==============================================================================
31 StoredSettings::StoredSettings()
33 flush();
36 StoredSettings::~StoredSettings()
38 flush();
39 props = nullptr;
40 clearSingletonInstance();
43 juce_ImplementSingleton (StoredSettings);
46 //==============================================================================
47 PropertiesFile& StoredSettings::getProps()
49 return *props;
52 void StoredSettings::flush()
54 if (props != nullptr)
56 props->setValue ("recentFiles", recentFiles.toString());
57 props->removeValue ("keyMappings");
59 ScopedPointer<XmlElement> keys (commandManager->getKeyMappings()->createXml (true));
61 if (keys != nullptr)
62 props->setValue ("keyMappings", keys);
64 for (int i = 0; i < swatchColours.size(); ++i)
65 props->setValue ("swatchColour" + String (i), colourToHex (swatchColours [i]));
68 props = nullptr;
71 PropertiesFile::Options options;
72 options.applicationName = "Jucer";
73 options.filenameSuffix = "settings";
74 options.osxLibrarySubFolder = "Preferences";
76 props = new PropertiesFile (options);
79 // recent files...
80 recentFiles.restoreFromString (props->getValue ("recentFiles"));
81 recentFiles.removeNonExistentFiles();
83 // swatch colours...
84 swatchColours.clear();
86 #define COL(col) Colours::col,
88 const Colour colours[] =
90 #include "jucer_Colours.h"
91 Colours::transparentBlack
94 #undef COL
96 for (int i = 0; i < numSwatchColours; ++i)
98 Colour defaultCol (colours [2 + i]);
100 swatchColours.add (Colour (props->getValue ("swatchColour" + String (i),
101 colourToHex (defaultCol)).getHexValue32()));
105 const File StoredSettings::getTemplatesDir() const
107 File defaultTemplateDir (File::getSpecialLocation (File::currentExecutableFile)
108 .getParentDirectory());
110 return File (props->getValue ("templateDir",
111 defaultTemplateDir.getFullPathName()));
114 void StoredSettings::setTemplatesDir (const File& newDir)
116 props->setValue ("templateDir", newDir.getFullPathName());